package com.juzipi.demo;

import java.util.ArrayList;

/**
 * @Author juzipi
 * @Date 2021/5/18 8:55
 * @Info
 */
public class TestVar {


    public static void main(String[] args) {

        ArrayList<String> name = new ArrayList<>();
        name.add("张三");
        name.add("张四");
        name.add("张五");
        name.add("张六");
        name.add("张七");
        name.add("张八");
        name.add("张九");
        for (var nam: name) {
            System.out.println(nam);
        }
        Shark shark = new Shark("小白","雄","大白鲨");
        ArrayList<Shark> sharks = new ArrayList<>();
        sharks.add(shark);
        for (var sha : sharks){
            System.out.println(sha);
        }


    }


}

class Shark{

    private String name;

    private String sex;

    private String variety;

    public Shark(String name, String sex, String variety) {
        this.name = name;
        this.sex = sex;
        this.variety = variety;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getVariety() {
        return variety;
    }

    public void setVariety(String variety) {
        this.variety = variety;
    }

    @Override
    public String toString() {
        return "Shark{" +
                "name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", variety='" + variety + '\'' +
                '}';
    }
}
